﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Net.Mime;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;

namespace NimbleTextKeygen
{
    [ComVisible(true)]
    [Obfuscation(Feature = "renaming", ApplyToMembers = true, Exclude = true)]
    public class CurrentSession
    {
        private readonly Icon Icon;

        private Settings Settings;


        public string Data
        {
            get;
            set;
        }

        public string DataName
        {
            get;
            set;
        }

        public float Factor
        {
            get;
            set;
        }

        public string FullFileNameAndPath
        {
            get;
            set;
        }

        public bool IsDirty
        {
            get;
            set;
        }

        public string Name
        {
            get;
            set;
        }

        public string Pattern
        {
            get;
            set;
        }

        public string PatternName
        {
            get;
            set;
        }

        public string Results
        {
            get;
            set;
        }

        public string ResultsName
        {
            get;
            set;
        }

        public string SessionName
        {
            get;
            set;
        }

        public CurrentSession(Icon icon, Settings settings, float factor)
        {
            this.Icon = icon;
            this.Settings = settings;
            this.Factor = factor;
        }

        public void AutoUpdated(string auto)
        {
            this.Settings.AutoPreview = auto == "True";
        }

       

        public float DisplayScaleFactor()
        {
            return this.Factor;
        }

        public bool Embedded()
        {
            return true;
        }

        public void Gone(string data, string pattern, string columnDelim, string rowDelim, string whereClause, string auto)
        {
            this.Settings.InputPattern = pattern;
            this.Settings.InputData = data;
            this.Settings.ColumnDelimiter = columnDelim;
            this.Settings.RowDelimiter = rowDelim;
            this.Settings.WhereClause = whereClause;
            this.Settings.AutoPreview = auto == "True";
        }

       

        public bool LogMessage(string msg)
        {
            Log.WriteLine(msg);
            return true;
        }


        public void OpenData()
        {
            if (this.OnOpenData != null)
            {
                this.OnOpenData();
            }
        }

        public void OpenSession()
        {
            if (this.OnOpenSession != null)
            {
                this.OnOpenSession();
            }
        }

        public void SaveResult()
        {
            if (this.OnSaveResult != null)
            {
                this.OnSaveResult();
            }
        }

        public void SaveSession()
        {
            if (this.OnSaveSession != null)
            {
                this.OnSaveSession();
            }
        }

        public event Action OnOpenData;

        public event Action OnOpenSession;

        public event Action OnSaveResult;

        public event Action OnSaveSession;
    }
}
